#include "common.h"

void GameNetwork::connectz()
{
	WORD	wVersion;
	WSADATA	wsaData;
	int		iError;

	wVersion = MAKEWORD(2, 0);

	iError = WSAStartup(wVersion, &wsaData);
	if (iError != 0)
	{
		return;
	}

	SOCKET		s;
	sockaddr_in saDestination;

	s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

	if (s == INVALID_SOCKET)
	{
		return;
	}

	saDestination.sin_family = AF_INET;
	saDestination.sin_addr.s_addr = inet_addr("127.0.0.1");
	saDestination.sin_port = htons(11899);

	if (bind(s, (SOCKADDR*)&saDestination, sizeof(saDestination)) == SOCKET_ERROR)
	{
		return;
	}
	
	if (listen(s, 1) == SOCKET_ERROR)
	{
		return;
	}
	
	SOCKET acceptedS;

	while (1)
	{
		acceptedS = SOCKET_ERROR;
		while (acceptedS == SOCKET_ERROR)
		{
			acceptedS = accept(s, NULL, NULL);
		}
		s = acceptedS;
		break;
	}
	WSACleanup();



}